<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>OptionsPricing: AssembleStiffnesMassMatrices.py Source File</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />

<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>

</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">OptionsPricing
   
   </div>
   
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.5.1 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li><a href="dirs.html"><span>Directories</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
    </ul>
  </div>
  <div id="nav-path" class="navpath">
    <ul>
      <li class="navelem"><a class="el" href="dir_ecbb14687e1bcdda1258b79279264b64.html">models</a>      </li>
    </ul>
  </div>
</div>
<div class="header">
  <div class="headertitle">
<div class="title">AssembleStiffnesMassMatrices.py</div>  </div>
</div>
<div class="contents">
<div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">#!/usr/bin/python</span>
<a name="l00002"></a>00002 <span class="comment"># -*- coding: utf-8 -*-</span>
<a name="l00003"></a>00003 
<a name="l00004"></a>00004 <span class="comment"># Copyright (c) 2011</span>
<a name="l00005"></a>00005 <span class="comment">#</span>
<a name="l00006"></a>00006 <span class="comment"># Permission is hereby granted, free of charge, to any person obtaining a</span>
<a name="l00007"></a>00007 <span class="comment"># copy of this software and associated documentation files (the &quot;Software&quot;),</span>
<a name="l00008"></a>00008 <span class="comment"># to deal in the Software without restriction, including without limitation</span>
<a name="l00009"></a>00009 <span class="comment"># the rights to use, copy, modify, merge, publish, distribute, sub license,</span>
<a name="l00010"></a>00010 <span class="comment"># and/or sell copies of the Software, and to permit persons to whom the</span>
<a name="l00011"></a>00011 <span class="comment"># Software is furnished to do so, subject to the following conditions:</span>
<a name="l00012"></a>00012 <span class="comment">#</span>
<a name="l00013"></a>00013 <span class="comment"># The above copyright notice and this permission notice shall be included in</span>
<a name="l00014"></a>00014 <span class="comment"># all copies or substantial portions of the Software.</span>
<a name="l00015"></a>00015 <span class="comment">#</span>
<a name="l00016"></a>00016 <span class="comment"># THE SOFTWARE IS PROVIDED &quot;AS IS&quot;, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR</span>
<a name="l00017"></a>00017 <span class="comment"># IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,</span>
<a name="l00018"></a>00018 <span class="comment"># FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE</span>
<a name="l00019"></a>00019 <span class="comment"># AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER</span>
<a name="l00020"></a>00020 <span class="comment"># LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,</span>
<a name="l00021"></a>00021 <span class="comment"># OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE</span>
<a name="l00022"></a>00022 <span class="comment"># SOFTWARE.</span>
<a name="l00023"></a>00023 <span class="comment">#</span>
<a name="l00024"></a>00024 <span class="comment"># Author: Jesus Carrero &lt;j.o.carrero@gmail.com&gt;</span>
<a name="l00025"></a>00025 <span class="comment"># Mountain View, CA</span>
<a name="l00026"></a>00026 <span class="comment">#</span>
<a name="l00027"></a>00027 
<a name="l00028"></a>00028 <span class="stringliteral">&quot;&quot;&quot; assemble pde matrices &quot;&quot;&quot;</span>
<a name="l00029"></a>00029 
<a name="l00030"></a>00030 <span class="keyword">from</span> scipy <span class="keyword">import</span> dot, diag, c_, zeros
<a name="l00031"></a>00031 
<a name="l00032"></a>00032 
<a name="l00033"></a><a class="code" href="classmodels_1_1AssembleStiffnesMassMatrices_1_1AssembleStiffnesMassMatrices.html">00033</a> <span class="keyword">class </span><a class="code" href="classmodels_1_1AssembleStiffnesMassMatrices_1_1AssembleStiffnesMassMatrices.html">AssembleStiffnesMassMatrices</a>(object):
<a name="l00034"></a>00034 
<a name="l00035"></a>00035     <span class="stringliteral">&quot;&quot;&quot;</span>
<a name="l00036"></a>00036 <span class="stringliteral">      Assemble mass and stiffness matrices.</span>
<a name="l00037"></a>00037 <span class="stringliteral">      The coefficients can be constant or given by splines.</span>
<a name="l00038"></a>00038 <span class="stringliteral">      Quadrature formulas are needed for numerical integration</span>
<a name="l00039"></a>00039 <span class="stringliteral">      ( Spline coefficients )</span>
<a name="l00040"></a>00040 <span class="stringliteral">      NOTE:</span>
<a name="l00041"></a>00041 <span class="stringliteral">        Assembling matrices for constant coefficient PDE&#39;s is trivial</span>
<a name="l00042"></a>00042 <span class="stringliteral">        and can be done much more efficiently than what is done here.</span>
<a name="l00043"></a>00043 <span class="stringliteral">        This class tries to unify the concept of &#39;assembling&#39; in general.</span>
<a name="l00044"></a>00044 <span class="stringliteral">        It encapsulate the fact that once you know the behavior at the</span>
<a name="l00045"></a>00045 <span class="stringliteral">        element level, the rest is just a matter of gluing them together.</span>
<a name="l00046"></a>00046 <span class="stringliteral">    &quot;&quot;&quot;</span>
<a name="l00047"></a>00047 
<a name="l00048"></a>00048     __slots__ = [<span class="stringliteral">&quot;m_grid&quot;</span>, <span class="stringliteral">&quot;m_basis&quot;</span>, <span class="stringliteral">&quot;m_quads&quot;</span>, <span class="stringliteral">&quot;m_c&quot;</span>, <span class="stringliteral">&quot;m_d&quot;</span>, <span class="stringliteral">&quot;m_r&quot;</span>,
<a name="l00049"></a>00049                  <span class="stringliteral">&quot;m_mass_diag&quot;</span>, <span class="stringliteral">&quot;m_reac_diag&quot;</span>, <span class="stringliteral">&quot;m_stiff_diag&quot;</span>, <span class="stringliteral">&quot;m_reac&quot;</span>,
<a name="l00050"></a>00050                  <span class="stringliteral">&quot;m_conv&quot;</span>, <span class="stringliteral">&quot;m_diff&quot;</span>, <span class="stringliteral">&quot;m_c_is_real&quot;</span>, <span class="stringliteral">&quot;m_d_is_real&quot;</span>,
<a name="l00051"></a>00051                  <span class="stringliteral">&quot;m_r_is_real&quot;</span>, <span class="stringliteral">&quot;m_der_at_quad&quot;</span>, <span class="stringliteral">&quot;m_shape_at_quad&quot;</span>, <span class="stringliteral">&quot;m_zero&quot;</span>]
<a name="l00052"></a>00052 
<a name="l00053"></a>00053     <span class="keyword">def </span>__init__(self, grid):
<a name="l00054"></a>00054         self.<a class="code" href="classmodels_1_1AssembleStiffnesMassMatrices_1_1AssembleStiffnesMassMatrices.html#a398d03d81a5deca40def48a5fee20448">m_grid</a> = grid
<a name="l00055"></a>00055         (self.m_basis, self.m_quads) = (<span class="keywordtype">None</span>, <span class="keywordtype">None</span>)
<a name="l00056"></a>00056 
<a name="l00057"></a>00057         (self.<a class="code" href="classmodels_1_1AssembleStiffnesMassMatrices_1_1AssembleStiffnesMassMatrices.html#aac2fef5930b9c8489f7d7c7b737ad670">m_c</a>, self.<a class="code" href="classmodels_1_1AssembleStiffnesMassMatrices_1_1AssembleStiffnesMassMatrices.html#a9eff014c0a02148673134a58205b32ff">m_d</a>, self.<a class="code" href="classmodels_1_1AssembleStiffnesMassMatrices_1_1AssembleStiffnesMassMatrices.html#ac465785e31fda61195b9831f370d6de9">m_r</a>) = (<span class="keywordtype">None</span>, <span class="keywordtype">None</span>, <span class="keywordtype">None</span>)
<a name="l00058"></a>00058         (self.<a class="code" href="classmodels_1_1AssembleStiffnesMassMatrices_1_1AssembleStiffnesMassMatrices.html#a61a3a07e7b06f01a3be8d0a5e90abc20">m_reac</a>, self.<a class="code" href="classmodels_1_1AssembleStiffnesMassMatrices_1_1AssembleStiffnesMassMatrices.html#a6937b45e81a21f0cd231dd65f48847c4">m_conv</a>, self.<a class="code" href="classmodels_1_1AssembleStiffnesMassMatrices_1_1AssembleStiffnesMassMatrices.html#a343c5cca68f08e0c4785d4e4955b2e30">m_diff</a>) = (<span class="keywordtype">None</span>, <span class="keywordtype">None</span>, <span class="keywordtype">None</span>)
<a name="l00059"></a>00059 
<a name="l00060"></a>00060         (self.<a class="code" href="classmodels_1_1AssembleStiffnesMassMatrices_1_1AssembleStiffnesMassMatrices.html#a442a68ad42121d93ffbd072ad157c395">m_mass_diag</a>, self.<a class="code" href="classmodels_1_1AssembleStiffnesMassMatrices_1_1AssembleStiffnesMassMatrices.html#aed9484da2e3714fc05584c0435d5e324">m_reac_diag</a>, self.<a class="code" href="classmodels_1_1AssembleStiffnesMassMatrices_1_1AssembleStiffnesMassMatrices.html#af92b483329240877df64751b73e56086">m_stiff_diag</a>) = \
<a name="l00061"></a>00061             (<span class="keywordtype">None</span>, <span class="keywordtype">None</span>, <span class="keywordtype">None</span>)
<a name="l00062"></a>00062 
<a name="l00063"></a>00063         (self.m_c_is_real, self.m_d_is_real, self.m_r_is_real) = \
<a name="l00064"></a>00064             (<span class="keyword">True</span>, <span class="keyword">True</span>, <span class="keyword">True</span>)
<a name="l00065"></a>00065 
<a name="l00066"></a>00066         (self.<a class="code" href="classmodels_1_1AssembleStiffnesMassMatrices_1_1AssembleStiffnesMassMatrices.html#ab204268908afbf9e3fb70147484078bc">m_der_at_quad</a>, self.<a class="code" href="classmodels_1_1AssembleStiffnesMassMatrices_1_1AssembleStiffnesMassMatrices.html#abf481840c4416642856fb007da9bd93d">m_shape_at_quad</a>) = (<span class="keywordtype">None</span>, <span class="keywordtype">None</span>)
<a name="l00067"></a>00067         self.<a class="code" href="classmodels_1_1AssembleStiffnesMassMatrices_1_1AssembleStiffnesMassMatrices.html#ae462666513b05f82ae869b4e1ff0fba1">m_zero</a> = <span class="keywordtype">None</span>
<a name="l00068"></a>00068 
<a name="l00069"></a><a class="code" href="classmodels_1_1AssembleStiffnesMassMatrices_1_1AssembleStiffnesMassMatrices.html#a327f3da1c9d0f0b176e38dc552b13841">00069</a>     <span class="keyword">def </span><a class="code" href="classmodels_1_1AssembleStiffnesMassMatrices_1_1AssembleStiffnesMassMatrices.html#a327f3da1c9d0f0b176e38dc552b13841">set_new_grid</a>(self, grid):
<a name="l00070"></a>00070         <span class="stringliteral">&quot;&quot;&quot; set new grid &quot;&quot;&quot;</span>
<a name="l00071"></a>00071 
<a name="l00072"></a>00072         self.<a class="code" href="classmodels_1_1AssembleStiffnesMassMatrices_1_1AssembleStiffnesMassMatrices.html#a398d03d81a5deca40def48a5fee20448">m_grid</a> = grid
<a name="l00073"></a>00073 
<a name="l00074"></a><a class="code" href="classmodels_1_1AssembleStiffnesMassMatrices_1_1AssembleStiffnesMassMatrices.html#ac648090923f735460094025dbb32eb0c">00074</a>     <span class="keyword">def </span><a class="code" href="classmodels_1_1AssembleStiffnesMassMatrices_1_1AssembleStiffnesMassMatrices.html#ac648090923f735460094025dbb32eb0c">set_sfunc_and_quads</a>(self, basis, quads):
<a name="l00075"></a>00075         <span class="stringliteral">&quot;&quot;&quot; set shape functions and quadrature points &quot;&quot;&quot;</span>
<a name="l00076"></a>00076 
<a name="l00077"></a>00077         (self.m_basis, self.m_quads) = (basis, quads)
<a name="l00078"></a>00078 
<a name="l00079"></a>00079         self.<a class="code" href="classmodels_1_1AssembleStiffnesMassMatrices_1_1AssembleStiffnesMassMatrices.html#a61a3a07e7b06f01a3be8d0a5e90abc20">m_reac</a> = self.m_basis.get_mass_mat()
<a name="l00080"></a>00080         self.<a class="code" href="classmodels_1_1AssembleStiffnesMassMatrices_1_1AssembleStiffnesMassMatrices.html#a6937b45e81a21f0cd231dd65f48847c4">m_conv</a> = self.m_basis.get_grad_disp()
<a name="l00081"></a>00081         self.<a class="code" href="classmodels_1_1AssembleStiffnesMassMatrices_1_1AssembleStiffnesMassMatrices.html#a343c5cca68f08e0c4785d4e4955b2e30">m_diff</a> = self.m_basis.get_grad_grad()
<a name="l00082"></a>00082         self.<a class="code" href="classmodels_1_1AssembleStiffnesMassMatrices_1_1AssembleStiffnesMassMatrices.html#ae462666513b05f82ae869b4e1ff0fba1">m_zero</a> = zeros(self.<a class="code" href="classmodels_1_1AssembleStiffnesMassMatrices_1_1AssembleStiffnesMassMatrices.html#a61a3a07e7b06f01a3be8d0a5e90abc20">m_reac</a>.shape)
<a name="l00083"></a>00083         self.<a class="code" href="classmodels_1_1AssembleStiffnesMassMatrices_1_1AssembleStiffnesMassMatrices.html#ab3fc3a7b0e7d27d478e8b508a0bbc84f">_shape_at_quad_pts</a>()
<a name="l00084"></a>00084 
<a name="l00085"></a><a class="code" href="classmodels_1_1AssembleStiffnesMassMatrices_1_1AssembleStiffnesMassMatrices.html#a99e5abc1b1aa10dd8b52f859384ce334">00085</a>     <span class="keyword">def </span><a class="code" href="classmodels_1_1AssembleStiffnesMassMatrices_1_1AssembleStiffnesMassMatrices.html#a99e5abc1b1aa10dd8b52f859384ce334">set_cos</a>(self, diff, conv, reac, d_is_real, c_is_real, r_is_real):
<a name="l00086"></a>00086         <span class="stringliteral">&quot;&quot;&quot; set pde coefficients &quot;&quot;&quot;</span>
<a name="l00087"></a>00087 
<a name="l00088"></a>00088         <span class="keywordflow">if</span> [] == diff:
<a name="l00089"></a>00089             self.<a class="code" href="classmodels_1_1AssembleStiffnesMassMatrices_1_1AssembleStiffnesMassMatrices.html#a9eff014c0a02148673134a58205b32ff">m_d</a> = <span class="keywordtype">None</span>
<a name="l00090"></a>00090         <span class="keywordflow">else</span>:
<a name="l00091"></a>00091             self.<a class="code" href="classmodels_1_1AssembleStiffnesMassMatrices_1_1AssembleStiffnesMassMatrices.html#a9eff014c0a02148673134a58205b32ff">m_d</a> = diff
<a name="l00092"></a>00092 
<a name="l00093"></a>00093         <span class="keywordflow">if</span> [] == conv:
<a name="l00094"></a>00094             self.<a class="code" href="classmodels_1_1AssembleStiffnesMassMatrices_1_1AssembleStiffnesMassMatrices.html#aac2fef5930b9c8489f7d7c7b737ad670">m_c</a> = <span class="keywordtype">None</span>
<a name="l00095"></a>00095         <span class="keywordflow">else</span>:
<a name="l00096"></a>00096             self.<a class="code" href="classmodels_1_1AssembleStiffnesMassMatrices_1_1AssembleStiffnesMassMatrices.html#aac2fef5930b9c8489f7d7c7b737ad670">m_c</a> = conv
<a name="l00097"></a>00097 
<a name="l00098"></a>00098         <span class="keywordflow">if</span> [] == reac:
<a name="l00099"></a>00099             self.<a class="code" href="classmodels_1_1AssembleStiffnesMassMatrices_1_1AssembleStiffnesMassMatrices.html#ac465785e31fda61195b9831f370d6de9">m_r</a> = <span class="keywordtype">None</span>
<a name="l00100"></a>00100         <span class="keywordflow">else</span>:
<a name="l00101"></a>00101             self.<a class="code" href="classmodels_1_1AssembleStiffnesMassMatrices_1_1AssembleStiffnesMassMatrices.html#ac465785e31fda61195b9831f370d6de9">m_r</a> = reac
<a name="l00102"></a>00102         (self.m_c_is_real, self.m_d_is_real, self.m_r_is_real) = \
<a name="l00103"></a>00103             (d_is_real, c_is_real, r_is_real)
<a name="l00104"></a>00104 
<a name="l00105"></a>00105     <span class="keyword">def </span>_reaccion_on_seg(self, i, delta_x, seg):
<a name="l00106"></a>00106         <span class="stringliteral">&quot;&quot;&quot; get reaction term on grid &quot;&quot;&quot;</span>
<a name="l00107"></a>00107 
<a name="l00108"></a>00108         <span class="keywordflow">if</span> self.<a class="code" href="classmodels_1_1AssembleStiffnesMassMatrices_1_1AssembleStiffnesMassMatrices.html#ac465785e31fda61195b9831f370d6de9">m_r</a> <span class="keywordflow">is</span> <span class="keywordtype">None</span>:
<a name="l00109"></a>00109             <span class="keywordflow">return</span> self.<a class="code" href="classmodels_1_1AssembleStiffnesMassMatrices_1_1AssembleStiffnesMassMatrices.html#ae462666513b05f82ae869b4e1ff0fba1">m_zero</a>
<a name="l00110"></a>00110 
<a name="l00111"></a>00111         <span class="keywordflow">if</span> self.m_r_is_real:
<a name="l00112"></a>00112             <span class="keywordflow">return</span> delta_x * self.<a class="code" href="classmodels_1_1AssembleStiffnesMassMatrices_1_1AssembleStiffnesMassMatrices.html#ac465785e31fda61195b9831f370d6de9">m_r</a> * self.<a class="code" href="classmodels_1_1AssembleStiffnesMassMatrices_1_1AssembleStiffnesMassMatrices.html#a61a3a07e7b06f01a3be8d0a5e90abc20">m_reac</a>
<a name="l00113"></a>00113 
<a name="l00114"></a>00114         <span class="keywordflow">return</span> self.<a class="code" href="classmodels_1_1AssembleStiffnesMassMatrices_1_1AssembleStiffnesMassMatrices.html#ad9e22e567801e1b25e90c04d97a19cc6">in_prod1</a>(seg, i, self.<a class="code" href="classmodels_1_1AssembleStiffnesMassMatrices_1_1AssembleStiffnesMassMatrices.html#ac465785e31fda61195b9831f370d6de9">m_r</a>, self.<a class="code" href="classmodels_1_1AssembleStiffnesMassMatrices_1_1AssembleStiffnesMassMatrices.html#abf481840c4416642856fb007da9bd93d">m_shape_at_quad</a>)
<a name="l00115"></a>00115 
<a name="l00116"></a>00116     <span class="keyword">def </span>_conv_on_seg(self, i, delta_x, seg):
<a name="l00117"></a>00117         <span class="stringliteral">&quot;&quot;&quot; get convection term on grid &quot;&quot;&quot;</span>
<a name="l00118"></a>00118         <span class="keywordflow">if</span> self.<a class="code" href="classmodels_1_1AssembleStiffnesMassMatrices_1_1AssembleStiffnesMassMatrices.html#aac2fef5930b9c8489f7d7c7b737ad670">m_c</a> <span class="keywordflow">is</span> <span class="keywordtype">None</span>:
<a name="l00119"></a>00119             <span class="keywordflow">return</span> self.<a class="code" href="classmodels_1_1AssembleStiffnesMassMatrices_1_1AssembleStiffnesMassMatrices.html#ae462666513b05f82ae869b4e1ff0fba1">m_zero</a>
<a name="l00120"></a>00120 
<a name="l00121"></a>00121         <span class="keywordflow">if</span> self.m_c_is_real:
<a name="l00122"></a>00122             <span class="keywordflow">return</span> self.<a class="code" href="classmodels_1_1AssembleStiffnesMassMatrices_1_1AssembleStiffnesMassMatrices.html#aac2fef5930b9c8489f7d7c7b737ad670">m_c</a> * self.<a class="code" href="classmodels_1_1AssembleStiffnesMassMatrices_1_1AssembleStiffnesMassMatrices.html#a6937b45e81a21f0cd231dd65f48847c4">m_conv</a>
<a name="l00123"></a>00123 
<a name="l00124"></a>00124         <span class="comment"># TODO the factor &#39;2&#39; shows up because the reference basis is</span>
<a name="l00125"></a>00125         <span class="comment"># defined in the interval [-1, 1] which is of length 2.</span>
<a name="l00126"></a>00126 
<a name="l00127"></a>00127         <span class="keywordflow">return</span> 2. * self.<a class="code" href="classmodels_1_1AssembleStiffnesMassMatrices_1_1AssembleStiffnesMassMatrices.html#a602d588af02ace47e86f1da2f01eb8e1">in_prod2</a>(seg, i, self.<a class="code" href="classmodels_1_1AssembleStiffnesMassMatrices_1_1AssembleStiffnesMassMatrices.html#aac2fef5930b9c8489f7d7c7b737ad670">m_c</a>,
<a name="l00128"></a>00128                                  self.<a class="code" href="classmodels_1_1AssembleStiffnesMassMatrices_1_1AssembleStiffnesMassMatrices.html#abf481840c4416642856fb007da9bd93d">m_shape_at_quad</a>,
<a name="l00129"></a>00129                                  self.<a class="code" href="classmodels_1_1AssembleStiffnesMassMatrices_1_1AssembleStiffnesMassMatrices.html#ab204268908afbf9e3fb70147484078bc">m_der_at_quad</a>) / delta_x
<a name="l00130"></a>00130 
<a name="l00131"></a><a class="code" href="classmodels_1_1AssembleStiffnesMassMatrices_1_1AssembleStiffnesMassMatrices.html#aa25fcbb16eec9c2af41a0e72aee8a9b3">00131</a>     <span class="keyword">def </span><a class="code" href="classmodels_1_1AssembleStiffnesMassMatrices_1_1AssembleStiffnesMassMatrices.html#aa25fcbb16eec9c2af41a0e72aee8a9b3">diffuse_on_seg</a>(self, i, delta_x, seg):
<a name="l00132"></a>00132         <span class="stringliteral">&quot;&quot;&quot; diffusion term on grid &quot;&quot;&quot;</span>
<a name="l00133"></a>00133 
<a name="l00134"></a>00134         <span class="keywordflow">if</span> self.<a class="code" href="classmodels_1_1AssembleStiffnesMassMatrices_1_1AssembleStiffnesMassMatrices.html#a9eff014c0a02148673134a58205b32ff">m_d</a> <span class="keywordflow">is</span> <span class="keywordtype">None</span>:
<a name="l00135"></a>00135             <span class="keywordflow">return</span> self.<a class="code" href="classmodels_1_1AssembleStiffnesMassMatrices_1_1AssembleStiffnesMassMatrices.html#ae462666513b05f82ae869b4e1ff0fba1">m_zero</a>
<a name="l00136"></a>00136 
<a name="l00137"></a>00137         <span class="keywordflow">if</span> self.m_d_is_real:
<a name="l00138"></a>00138             <span class="keywordflow">return</span> -self.<a class="code" href="classmodels_1_1AssembleStiffnesMassMatrices_1_1AssembleStiffnesMassMatrices.html#a9eff014c0a02148673134a58205b32ff">m_d</a> * self.<a class="code" href="classmodels_1_1AssembleStiffnesMassMatrices_1_1AssembleStiffnesMassMatrices.html#a343c5cca68f08e0c4785d4e4955b2e30">m_diff</a> / delta_x
<a name="l00139"></a>00139 
<a name="l00140"></a>00140         <span class="keywordflow">return</span> -4 * self.<a class="code" href="classmodels_1_1AssembleStiffnesMassMatrices_1_1AssembleStiffnesMassMatrices.html#ad9e22e567801e1b25e90c04d97a19cc6">in_prod1</a>(seg, i, self.<a class="code" href="classmodels_1_1AssembleStiffnesMassMatrices_1_1AssembleStiffnesMassMatrices.html#a9eff014c0a02148673134a58205b32ff">m_d</a>, self.<a class="code" href="classmodels_1_1AssembleStiffnesMassMatrices_1_1AssembleStiffnesMassMatrices.html#ab204268908afbf9e3fb70147484078bc">m_der_at_quad</a>) \
<a name="l00141"></a>00141             / delta_x ** 2
<a name="l00142"></a>00142 
<a name="l00143"></a>00143     <span class="keyword">def </span>__mass_matrix(self):
<a name="l00144"></a>00144         <span class="stringliteral">&quot;&quot;&quot;</span>
<a name="l00145"></a>00145 <span class="stringliteral">       In finite elements the grid does not have to be uniform</span>
<a name="l00146"></a>00146 <span class="stringliteral">       That&#39;s why we have to use loops to assemble the matrices.</span>
<a name="l00147"></a>00147 <span class="stringliteral">    &quot;&quot;&quot;</span>
<a name="l00148"></a>00148 
<a name="l00149"></a>00149         delta_x = self.m_grid.getDx()
<a name="l00150"></a>00150         nsegs = self.m_grid.getNumSegs()
<a name="l00151"></a>00151 
<a name="l00152"></a>00152         mass_mat = self.m_basis.get_mass_mat()
<a name="l00153"></a>00153 
<a name="l00154"></a>00154         dof = self.m_basis.dof()
<a name="l00155"></a>00155         dim = (dof - 1) * nsegs + 1
<a name="l00156"></a>00156         diag0 = zeros((dim, 1))
<a name="l00157"></a>00157 
<a name="l00158"></a>00158         sdiag = diag(mass_mat)
<a name="l00159"></a>00159         sdiag = sdiag.reshape((dof, 1))
<a name="l00160"></a>00160         <span class="keywordflow">for</span> (i, delta_xi) <span class="keywordflow">in</span> enumerate(delta_x):
<a name="l00161"></a>00161             diag0[(dof - 1) * i:(dof - 1) * i + dof] += sdiag * delta_xi
<a name="l00162"></a>00162 
<a name="l00163"></a>00163         diag0 = diag0.flatten()
<a name="l00164"></a>00164         <span class="keywordflow">if</span> 2 == dof:
<a name="l00165"></a>00165             diag1 = mass_mat[0, 1] * delta_x.flatten()
<a name="l00166"></a>00166             self.<a class="code" href="classmodels_1_1AssembleStiffnesMassMatrices_1_1AssembleStiffnesMassMatrices.html#a442a68ad42121d93ffbd072ad157c395">m_mass_diag</a> = zeros((diag0.size, 3))
<a name="l00167"></a>00167 
<a name="l00168"></a>00168         <span class="keywordflow">if</span> 3 == dof:
<a name="l00169"></a>00169             diag1 = (diag(mass_mat, 1) * c_[delta_x, delta_x]).flatten()
<a name="l00170"></a>00170             diag2 = mass_mat[0, 2] * c_[delta_x,
<a name="l00171"></a>00171                     zeros(delta_x.shape)].flatten()
<a name="l00172"></a>00172             self.<a class="code" href="classmodels_1_1AssembleStiffnesMassMatrices_1_1AssembleStiffnesMassMatrices.html#a442a68ad42121d93ffbd072ad157c395">m_mass_diag</a> = zeros((diag0.size, 5))
<a name="l00173"></a>00173             self.<a class="code" href="classmodels_1_1AssembleStiffnesMassMatrices_1_1AssembleStiffnesMassMatrices.html#a442a68ad42121d93ffbd072ad157c395">m_mass_diag</a>[2:, 3] = diag2[:-1]
<a name="l00174"></a>00174             self.<a class="code" href="classmodels_1_1AssembleStiffnesMassMatrices_1_1AssembleStiffnesMassMatrices.html#a442a68ad42121d93ffbd072ad157c395">m_mass_diag</a>[:-1, 4] = diag2
<a name="l00175"></a>00175 
<a name="l00176"></a>00176             diag2 = diag2[0:-1].flatten()
<a name="l00177"></a>00177 
<a name="l00178"></a>00178         self.<a class="code" href="classmodels_1_1AssembleStiffnesMassMatrices_1_1AssembleStiffnesMassMatrices.html#a442a68ad42121d93ffbd072ad157c395">m_mass_diag</a>[:, 0] = diag0
<a name="l00179"></a>00179         self.<a class="code" href="classmodels_1_1AssembleStiffnesMassMatrices_1_1AssembleStiffnesMassMatrices.html#a442a68ad42121d93ffbd072ad157c395">m_mass_diag</a>[1:, 1] = diag1.copy()
<a name="l00180"></a>00180         self.<a class="code" href="classmodels_1_1AssembleStiffnesMassMatrices_1_1AssembleStiffnesMassMatrices.html#a442a68ad42121d93ffbd072ad157c395">m_mass_diag</a>[:-1, 2] = diag1.copy()
<a name="l00181"></a>00181 
<a name="l00182"></a>00182     <span class="keyword">def </span>_react_matrix(self):
<a name="l00183"></a>00183         <span class="stringliteral">&quot;&quot;&quot; construct reaction matrix &quot;&quot;&quot;</span>
<a name="l00184"></a>00184 
<a name="l00185"></a>00185         delta_x = self.m_grid.getDx()
<a name="l00186"></a>00186         segs = self.m_grid.getSegments()
<a name="l00187"></a>00187         dof = self.m_basis.dof()
<a name="l00188"></a>00188 
<a name="l00189"></a>00189         dim = (dof - 1) * self.m_grid.getNumSegs() + 1
<a name="l00190"></a>00190         diag0 = zeros((dim, 1))
<a name="l00191"></a>00191         diag1 = zeros((dim - 1, 1))
<a name="l00192"></a>00192 
<a name="l00193"></a>00193         <span class="keywordflow">if</span> 2 == dof:
<a name="l00194"></a>00194             self.<a class="code" href="classmodels_1_1AssembleStiffnesMassMatrices_1_1AssembleStiffnesMassMatrices.html#aed9484da2e3714fc05584c0435d5e324">m_reac_diag</a> = zeros((diag0.size, 3))
<a name="l00195"></a>00195             <span class="keywordflow">for</span> (i, delta_xi) <span class="keywordflow">in</span> enumerate(delta_x):
<a name="l00196"></a>00196                 mass_mat = self.<a class="code" href="classmodels_1_1AssembleStiffnesMassMatrices_1_1AssembleStiffnesMassMatrices.html#a120a395436e17c9bf236a6eb477ca170">_reaccion_on_seg</a>(i, delta_xi, segs[i])
<a name="l00197"></a>00197                 diag0[(dof - 1) * i:(dof - 1) * i + dof] += \
<a name="l00198"></a>00198                     diag(mass_mat).reshape((2, 1))
<a name="l00199"></a>00199                 diag1[i] = mass_mat[0, 1]
<a name="l00200"></a>00200 
<a name="l00201"></a>00201         <span class="keywordflow">if</span> 3 == dof:
<a name="l00202"></a>00202             diag2 = zeros((dim - 1, 1))
<a name="l00203"></a>00203             self.<a class="code" href="classmodels_1_1AssembleStiffnesMassMatrices_1_1AssembleStiffnesMassMatrices.html#aed9484da2e3714fc05584c0435d5e324">m_reac_diag</a> = zeros((diag0.size, 5))
<a name="l00204"></a>00204             <span class="keywordflow">for</span> (i, delta_xi) <span class="keywordflow">in</span> enumerate(delta_x):
<a name="l00205"></a>00205                 mass_mat = self.<a class="code" href="classmodels_1_1AssembleStiffnesMassMatrices_1_1AssembleStiffnesMassMatrices.html#a120a395436e17c9bf236a6eb477ca170">_reaccion_on_seg</a>(i, delta_xi, segs[i])
<a name="l00206"></a>00206                 diag0[(dof - 1) * i:(dof - 1) * i + dof] += \
<a name="l00207"></a>00207                     diag(mass_mat).reshape((3, 1))
<a name="l00208"></a>00208                 diag1[2 * i:2 * (i + 1)] = diag(mass_mat,
<a name="l00209"></a>00209                         1).reshape((2, 1))
<a name="l00210"></a>00210                 diag2[2 * i] = mass_mat[0, 2]
<a name="l00211"></a>00211             diag2 = diag2.flatten()
<a name="l00212"></a>00212             self.<a class="code" href="classmodels_1_1AssembleStiffnesMassMatrices_1_1AssembleStiffnesMassMatrices.html#aed9484da2e3714fc05584c0435d5e324">m_reac_diag</a>[2:, 3] = diag2[:-1]
<a name="l00213"></a>00213             self.<a class="code" href="classmodels_1_1AssembleStiffnesMassMatrices_1_1AssembleStiffnesMassMatrices.html#aed9484da2e3714fc05584c0435d5e324">m_reac_diag</a>[:-1, 4] = diag2
<a name="l00214"></a>00214 
<a name="l00215"></a>00215         diag0 = diag0.flatten()
<a name="l00216"></a>00216         diag1 = diag1.flatten()
<a name="l00217"></a>00217         self.<a class="code" href="classmodels_1_1AssembleStiffnesMassMatrices_1_1AssembleStiffnesMassMatrices.html#aed9484da2e3714fc05584c0435d5e324">m_reac_diag</a>[:, 0] = diag0
<a name="l00218"></a>00218         self.<a class="code" href="classmodels_1_1AssembleStiffnesMassMatrices_1_1AssembleStiffnesMassMatrices.html#aed9484da2e3714fc05584c0435d5e324">m_reac_diag</a>[1:, 1] = diag1.copy()
<a name="l00219"></a>00219         self.<a class="code" href="classmodels_1_1AssembleStiffnesMassMatrices_1_1AssembleStiffnesMassMatrices.html#aed9484da2e3714fc05584c0435d5e324">m_reac_diag</a>[:-1, 2] = diag1.copy()
<a name="l00220"></a>00220 
<a name="l00221"></a><a class="code" href="classmodels_1_1AssembleStiffnesMassMatrices_1_1AssembleStiffnesMassMatrices.html#a063c1fe8d467e658d44d3062303f06f2">00221</a>     <span class="keyword">def </span><a class="code" href="classmodels_1_1AssembleStiffnesMassMatrices_1_1AssembleStiffnesMassMatrices.html#a063c1fe8d467e658d44d3062303f06f2">discretize</a>(self):
<a name="l00222"></a>00222         <span class="stringliteral">&quot;&quot;&quot;</span>
<a name="l00223"></a>00223 <span class="stringliteral">      assemble the stiffness matrix:</span>
<a name="l00224"></a>00224 <span class="stringliteral">        d*u_xx + c*u_x + r*u</span>
<a name="l00225"></a>00225 <span class="stringliteral"></span>
<a name="l00226"></a>00226 <span class="stringliteral">        d ~ diffusion</span>
<a name="l00227"></a>00227 <span class="stringliteral">        c ~ convection</span>
<a name="l00228"></a>00228 <span class="stringliteral">        r ~ reaction</span>
<a name="l00229"></a>00229 <span class="stringliteral">    &quot;&quot;&quot;</span>
<a name="l00230"></a>00230 
<a name="l00231"></a>00231         delta_x = self.m_grid.getDx()
<a name="l00232"></a>00232         segs = self.m_grid.getSegments()
<a name="l00233"></a>00233         dof = self.m_basis.dof()
<a name="l00234"></a>00234 
<a name="l00235"></a>00235         dim = (dof - 1) * self.m_grid.getNumSegs() + 1
<a name="l00236"></a>00236         diag0 = zeros((dim, 1))
<a name="l00237"></a>00237         diag1 = zeros((dim - 1, 1))
<a name="l00238"></a>00238         diag_1 = zeros((dim - 1, 1))
<a name="l00239"></a>00239 
<a name="l00240"></a>00240         <span class="keywordflow">if</span> 2 == dof:
<a name="l00241"></a>00241             self.<a class="code" href="classmodels_1_1AssembleStiffnesMassMatrices_1_1AssembleStiffnesMassMatrices.html#af92b483329240877df64751b73e56086">m_stiff_diag</a> = zeros((diag0.size, 3))
<a name="l00242"></a>00242             <span class="keywordflow">for</span> (i, delta_xi) <span class="keywordflow">in</span> enumerate(delta_x):
<a name="l00243"></a>00243                 conv_mat = self.<a class="code" href="classmodels_1_1AssembleStiffnesMassMatrices_1_1AssembleStiffnesMassMatrices.html#acb9785afcd3291801120fd84b66fa149">_conv_on_seg</a>(i, delta_xi, segs[i])
<a name="l00244"></a>00244                 diff_mat = self.<a class="code" href="classmodels_1_1AssembleStiffnesMassMatrices_1_1AssembleStiffnesMassMatrices.html#aa25fcbb16eec9c2af41a0e72aee8a9b3">diffuse_on_seg</a>(i, delta_xi, segs[i])
<a name="l00245"></a>00245                 tmp = conv_mat + diff_mat
<a name="l00246"></a>00246                 diag0[(dof - 1) * i:(dof - 1) * i + dof] += \
<a name="l00247"></a>00247                     diag(tmp).reshape((2, 1))
<a name="l00248"></a>00248                 diag1[i] = tmp[0, 1]
<a name="l00249"></a>00249                 diag_1[i] = tmp[1, 0]
<a name="l00250"></a>00250 
<a name="l00251"></a>00251         <span class="keywordflow">if</span> 3 == dof:
<a name="l00252"></a>00252             diag2 = zeros((dim - 1, 1))
<a name="l00253"></a>00253             diag_2 = zeros((dim - 1, 1))
<a name="l00254"></a>00254             self.<a class="code" href="classmodels_1_1AssembleStiffnesMassMatrices_1_1AssembleStiffnesMassMatrices.html#af92b483329240877df64751b73e56086">m_stiff_diag</a> = zeros((diag0.size, 5))
<a name="l00255"></a>00255             <span class="keywordflow">for</span> (i, delta_xi) <span class="keywordflow">in</span> enumerate(delta_x):
<a name="l00256"></a>00256                 conv_mat = self.<a class="code" href="classmodels_1_1AssembleStiffnesMassMatrices_1_1AssembleStiffnesMassMatrices.html#acb9785afcd3291801120fd84b66fa149">_conv_on_seg</a>(i, delta_xi, segs[i])
<a name="l00257"></a>00257                 diff_mat = self.<a class="code" href="classmodels_1_1AssembleStiffnesMassMatrices_1_1AssembleStiffnesMassMatrices.html#aa25fcbb16eec9c2af41a0e72aee8a9b3">diffuse_on_seg</a>(i, delta_xi, segs[i])
<a name="l00258"></a>00258                 tmp = conv_mat + diff_mat
<a name="l00259"></a>00259                 diag0[2 * i:2 * i + 3] += diag(tmp).reshape((3, 1))
<a name="l00260"></a>00260 
<a name="l00261"></a>00261                 diag1[2 * i:2 * (i + 1)] = diag(tmp, 1).reshape((2, 1))
<a name="l00262"></a>00262                 diag_1[2 * i:2 * (i + 1)] = diag(tmp, -1).reshape((2,
<a name="l00263"></a>00263                         1))
<a name="l00264"></a>00264 
<a name="l00265"></a>00265                 diag2[2 * i] = tmp[0, 2]
<a name="l00266"></a>00266                 diag_2[2 * i] = tmp[2, 0]
<a name="l00267"></a>00267 
<a name="l00268"></a>00268             diag2 = diag2.flatten()
<a name="l00269"></a>00269             diag_2 = diag_2.flatten()
<a name="l00270"></a>00270             self.<a class="code" href="classmodels_1_1AssembleStiffnesMassMatrices_1_1AssembleStiffnesMassMatrices.html#af92b483329240877df64751b73e56086">m_stiff_diag</a>[2:, 3] = diag2[:-1]
<a name="l00271"></a>00271             self.<a class="code" href="classmodels_1_1AssembleStiffnesMassMatrices_1_1AssembleStiffnesMassMatrices.html#af92b483329240877df64751b73e56086">m_stiff_diag</a>[:-1, 4] = diag_2
<a name="l00272"></a>00272 
<a name="l00273"></a>00273         diag0 = diag0.flatten()
<a name="l00274"></a>00274         diag1 = diag1.flatten()
<a name="l00275"></a>00275         diag_1 = diag_1.flatten()
<a name="l00276"></a>00276         self.<a class="code" href="classmodels_1_1AssembleStiffnesMassMatrices_1_1AssembleStiffnesMassMatrices.html#af92b483329240877df64751b73e56086">m_stiff_diag</a>[:, 0] = diag0
<a name="l00277"></a>00277         self.<a class="code" href="classmodels_1_1AssembleStiffnesMassMatrices_1_1AssembleStiffnesMassMatrices.html#af92b483329240877df64751b73e56086">m_stiff_diag</a>[1:, 1] = diag1.copy()
<a name="l00278"></a>00278         self.<a class="code" href="classmodels_1_1AssembleStiffnesMassMatrices_1_1AssembleStiffnesMassMatrices.html#af92b483329240877df64751b73e56086">m_stiff_diag</a>[:-1, 2] = diag_1.copy()
<a name="l00279"></a>00279 
<a name="l00280"></a>00280         <span class="keywordflow">if</span> self.<a class="code" href="classmodels_1_1AssembleStiffnesMassMatrices_1_1AssembleStiffnesMassMatrices.html#ac465785e31fda61195b9831f370d6de9">m_r</a> <span class="keywordflow">is</span> <span class="keywordtype">None</span> <span class="keywordflow">or</span> self.m_r_is_real <span class="keywordflow">and</span> 0 == abs(self.<a class="code" href="classmodels_1_1AssembleStiffnesMassMatrices_1_1AssembleStiffnesMassMatrices.html#ac465785e31fda61195b9831f370d6de9">m_r</a>):
<a name="l00281"></a>00281             <span class="keywordflow">return</span>
<a name="l00282"></a>00282 
<a name="l00283"></a>00283         self.<a class="code" href="classmodels_1_1AssembleStiffnesMassMatrices_1_1AssembleStiffnesMassMatrices.html#ab82cb1ebdd9d7881aa05a21da5033c9b">_react_matrix</a>()
<a name="l00284"></a>00284         self.<a class="code" href="classmodels_1_1AssembleStiffnesMassMatrices_1_1AssembleStiffnesMassMatrices.html#af92b483329240877df64751b73e56086">m_stiff_diag</a> += self.<a class="code" href="classmodels_1_1AssembleStiffnesMassMatrices_1_1AssembleStiffnesMassMatrices.html#aed9484da2e3714fc05584c0435d5e324">m_reac_diag</a>
<a name="l00285"></a>00285 
<a name="l00286"></a><a class="code" href="classmodels_1_1AssembleStiffnesMassMatrices_1_1AssembleStiffnesMassMatrices.html#a1c625bd4bd686994044b0073dbc09b7b">00286</a>     <span class="keyword">def </span><a class="code" href="classmodels_1_1AssembleStiffnesMassMatrices_1_1AssembleStiffnesMassMatrices.html#a1c625bd4bd686994044b0073dbc09b7b">get_pdecos</a>(self):
<a name="l00287"></a>00287         <span class="stringliteral">&quot;&quot;&quot; Coeffients used to assemble the Matrices. &quot;&quot;&quot;</span>
<a name="l00288"></a>00288 
<a name="l00289"></a>00289         <span class="keywordflow">return</span> (self.<a class="code" href="classmodels_1_1AssembleStiffnesMassMatrices_1_1AssembleStiffnesMassMatrices.html#a9eff014c0a02148673134a58205b32ff">m_d</a>, self.<a class="code" href="classmodels_1_1AssembleStiffnesMassMatrices_1_1AssembleStiffnesMassMatrices.html#aac2fef5930b9c8489f7d7c7b737ad670">m_c</a>, self.<a class="code" href="classmodels_1_1AssembleStiffnesMassMatrices_1_1AssembleStiffnesMassMatrices.html#ac465785e31fda61195b9831f370d6de9">m_r</a>)
<a name="l00290"></a>00290 
<a name="l00291"></a><a class="code" href="classmodels_1_1AssembleStiffnesMassMatrices_1_1AssembleStiffnesMassMatrices.html#aa9b896fe88236a6684578c31a6592655">00291</a>     <span class="keyword">def </span><a class="code" href="classmodels_1_1AssembleStiffnesMassMatrices_1_1AssembleStiffnesMassMatrices.html#aa9b896fe88236a6684578c31a6592655">get_mass_mat</a>(self):
<a name="l00292"></a>00292         <span class="stringliteral">&quot;&quot;&quot; get mass matrix. &quot;&quot;&quot;</span>
<a name="l00293"></a>00293 
<a name="l00294"></a>00294         <span class="keywordflow">if</span> self.<a class="code" href="classmodels_1_1AssembleStiffnesMassMatrices_1_1AssembleStiffnesMassMatrices.html#a442a68ad42121d93ffbd072ad157c395">m_mass_diag</a> <span class="keywordflow">is</span> <span class="keywordtype">None</span>:
<a name="l00295"></a>00295             self.<a class="code" href="classmodels_1_1AssembleStiffnesMassMatrices_1_1AssembleStiffnesMassMatrices.html#a86aeefcb9b488611fb7ada719d79f402">__mass_matrix</a>()
<a name="l00296"></a>00296         <span class="keywordflow">return</span> self.<a class="code" href="classmodels_1_1AssembleStiffnesMassMatrices_1_1AssembleStiffnesMassMatrices.html#a442a68ad42121d93ffbd072ad157c395">m_mass_diag</a>
<a name="l00297"></a>00297 
<a name="l00298"></a><a class="code" href="classmodels_1_1AssembleStiffnesMassMatrices_1_1AssembleStiffnesMassMatrices.html#a352c255d348b47fbf614414e2109c2df">00298</a>     <span class="keyword">def </span><a class="code" href="classmodels_1_1AssembleStiffnesMassMatrices_1_1AssembleStiffnesMassMatrices.html#a352c255d348b47fbf614414e2109c2df">get_stiffness</a>(self):
<a name="l00299"></a>00299         <span class="stringliteral">&quot;&quot;&quot; get stiffness matrix. &quot;&quot;&quot;</span>
<a name="l00300"></a>00300 
<a name="l00301"></a>00301         <span class="keywordflow">return</span> self.<a class="code" href="classmodels_1_1AssembleStiffnesMassMatrices_1_1AssembleStiffnesMassMatrices.html#af92b483329240877df64751b73e56086">m_stiff_diag</a>
<a name="l00302"></a>00302 
<a name="l00303"></a><a class="code" href="classmodels_1_1AssembleStiffnesMassMatrices_1_1AssembleStiffnesMassMatrices.html#ad9e22e567801e1b25e90c04d97a19cc6">00303</a>     <span class="keyword">def </span><a class="code" href="classmodels_1_1AssembleStiffnesMassMatrices_1_1AssembleStiffnesMassMatrices.html#ad9e22e567801e1b25e90c04d97a19cc6">in_prod1</a>(self, seg, i, spl, shape_at_quads):
<a name="l00304"></a>00304         <span class="stringliteral">&quot;&quot;&quot; inner product on splines. &quot;&quot;&quot;</span>
<a name="l00305"></a>00305 
<a name="l00306"></a>00306         (xleft, xright) = seg
<a name="l00307"></a>00307         length = xright - xleft
<a name="l00308"></a>00308 
<a name="l00309"></a>00309         lqpoints = xleft + length * self.m_quads.get_qpoints()
<a name="l00310"></a>00310         spl_at_quads = spl.value(lqpoints, i)  <span class="comment"># Spline values</span>
<a name="l00311"></a>00311         spl_at_quads = (spl_at_quads * self.m_quads.get_weights()
<a name="l00312"></a>00312                         / 2.).flatten()  <span class="comment"># apply quad weights.</span>
<a name="l00313"></a>00313 
<a name="l00314"></a>00314         dim1 = shape_at_quads.shape[0]
<a name="l00315"></a>00315         inn = zeros((dim1, dim1))
<a name="l00316"></a>00316         <span class="keywordflow">for</span> (i, gr0) <span class="keywordflow">in</span> enumerate(shape_at_quads):
<a name="l00317"></a>00317             gr1 = gr0 * spl_at_quads
<a name="l00318"></a>00318             <span class="keywordflow">for</span> (j, gr2) <span class="keywordflow">in</span> enumerate(shape_at_quads):
<a name="l00319"></a>00319                 inn[i, j] = length * dot(gr1, gr2)
<a name="l00320"></a>00320         <span class="keywordflow">return</span> inn
<a name="l00321"></a>00321 
<a name="l00322"></a><a class="code" href="classmodels_1_1AssembleStiffnesMassMatrices_1_1AssembleStiffnesMassMatrices.html#a602d588af02ace47e86f1da2f01eb8e1">00322</a>     <span class="keyword">def </span><a class="code" href="classmodels_1_1AssembleStiffnesMassMatrices_1_1AssembleStiffnesMassMatrices.html#a602d588af02ace47e86f1da2f01eb8e1">in_prod2</a>(self, seg, i, spl, shape_at_quads1, shape_at_quads2):
<a name="l00323"></a>00323         <span class="stringliteral">&quot;&quot;&quot; inner product on splines. &quot;&quot;&quot;</span>
<a name="l00324"></a>00324 
<a name="l00325"></a>00325         (xleft, xright) = seg
<a name="l00326"></a>00326         length = xright - xleft
<a name="l00327"></a>00327 
<a name="l00328"></a>00328         lqpoints = xleft + length * self.m_quads.get_qpoints()
<a name="l00329"></a>00329         spl_at_quads = spl.value(lqpoints, i)  <span class="comment"># Spline values</span>
<a name="l00330"></a>00330         spl_at_quads = (spl_at_quads * self.m_quads.get_weights()
<a name="l00331"></a>00331                         / 2.).flatten()  <span class="comment"># apply quad weights.</span>
<a name="l00332"></a>00332 
<a name="l00333"></a>00333         dim1 = shape_at_quads1.shape[0]
<a name="l00334"></a>00334         inn = zeros((dim1, dim1))
<a name="l00335"></a>00335         <span class="keywordflow">for</span> (i, gr0) <span class="keywordflow">in</span> enumerate(shape_at_quads1):
<a name="l00336"></a>00336             gr1 = gr0 * spl_at_quads
<a name="l00337"></a>00337             <span class="keywordflow">for</span> (j, gr2) <span class="keywordflow">in</span> enumerate(shape_at_quads2):
<a name="l00338"></a>00338                 inn[i, j] = length * dot(gr1, gr2)
<a name="l00339"></a>00339         <span class="keywordflow">return</span> inn
<a name="l00340"></a>00340 
<a name="l00341"></a>00341     <span class="keyword">def </span>_shape_at_quad_pts(self):
<a name="l00342"></a>00342         <span class="stringliteral">&quot;&quot;&quot; values shape function at quad points. &quot;&quot;&quot;</span>
<a name="l00343"></a>00343 
<a name="l00344"></a>00344         qpoints = self.m_quads.get_qpoints()
<a name="l00345"></a>00345         <span class="comment">#xlimits = self.m_basis.shape_func_support()</span>
<a name="l00346"></a>00346 
<a name="l00347"></a>00347         <span class="comment">#qpoints1 = (xlimits[1] - xlimits[0]) * (1. + qpoints + xlimits[0]) / 2.</span>
<a name="l00348"></a>00348         self.<a class="code" href="classmodels_1_1AssembleStiffnesMassMatrices_1_1AssembleStiffnesMassMatrices.html#ab204268908afbf9e3fb70147484078bc">m_der_at_quad</a> = self.m_basis.derivatives(qpoints)
<a name="l00349"></a>00349         self.<a class="code" href="classmodels_1_1AssembleStiffnesMassMatrices_1_1AssembleStiffnesMassMatrices.html#abf481840c4416642856fb007da9bd93d">m_shape_at_quad</a> = self.m_basis.values(qpoints)
<a name="l00350"></a>00350         <span class="keyword">assert</span> self.<a class="code" href="classmodels_1_1AssembleStiffnesMassMatrices_1_1AssembleStiffnesMassMatrices.html#ab204268908afbf9e3fb70147484078bc">m_der_at_quad</a>.shape == self.<a class="code" href="classmodels_1_1AssembleStiffnesMassMatrices_1_1AssembleStiffnesMassMatrices.html#abf481840c4416642856fb007da9bd93d">m_shape_at_quad</a>.shape
<a name="l00351"></a>00351 
<a name="l00352"></a>00352 
</pre></div></div>
</div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Functions</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>



<hr class="footer"/><address class="footer"><small>
Generated on Thu Dec 22 2011 05:17:53 for OptionsPricing by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.7.5.1
</small></address>

</body>
</html>
